import java.io.*;
import java.sql.SQLOutput;
import java.util.Date;

public class FileDemo {
    public static void main(String[] args) {
        File f = new File("d://aa123.txt");
        if(f.exists()) {
            System.out.println("exists");
            System.out.println(f.getAbsoluteFile());
            System.out.println(f.getName());
            System.out.println(f.length());
            System.out.println(f.lastModified());//long型（命令）

            Date d = new Date(f.lastModified());
            System.out.println(d);
        } else {
          //f.mkdir();//创建文件
            try {
                f.createNewFile();//创建目录
                FileWriter fw = new FileWriter(f);//写内容，输出流
                fw.write("hello");
                fw.flush();
                fw.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
